<?php

use App\Models\Activity\ActivityActionModel;
use App\Models\Activity\ActivityModel;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateActivityAction extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('activity_action', function (Blueprint $table) {
            $table->id();

            $table->unsignedBigInteger("activityId")->default(0)->comment("活动id activity.id");
            $table->unsignedTinyInteger("actionType")->default(0)->comment(
                enumToMigrationComment(ActivityActionModel::ACTION_TYPE_TEXT)
            );
            $table->string("name", 120)->default("")->comment("动作名称");
            $table->text("remark")->default("")->comment("备注说明");

            $table->unsignedBigInteger("price")->default(0)->comment("项目参加费用(实付金额) 分");
            $table->unsignedBigInteger("originalPrice")->default(0)->comment("项目参加费用(原价) 分");
            $table->unsignedBigInteger("goodsId")->default(0)->comment("项目关联订货商品id");
            $table->unsignedBigInteger("goodsNum")->default(0)->comment("项目商品数量");
            $table->json("goodsInfo")->nullable(true)->comment("订货商品信息");
            $table->unsignedTinyInteger("shippingAddressType")->default(0)->comment(
                enumToMigrationComment(ActivityActionModel::SHIPPING_ADDRESS_TEXT, "配送地址选项类型")
            );

            $table->unsignedBigInteger("formTemplateId")->default(0)->comment("表单id");
            $table->unsignedBigInteger("examineSwitch")->default(0)->comment("审核开关");
            $table->json("examineUser")->nullable(true)->comment("审批人");

            $table->string("groupNotificationBotName")->default("")->comment("群通知机器人名称");
            $table->string("groupNotificationBotWebhook")->default("")->comment("群通知机器人Webhook");
            $table->string("groupNotificationBotSecret")->default("")->comment("群通知机器人秘钥");


            $table->unsignedTinyInteger("hiddenSwitch")->default(0)->comment(
                enumToMigrationComment(ActivityModel::SWITCH_TEXT, "隐藏开关")
            );
            $table->unsignedBigInteger("sort")->default(0)->comment("展示排序");
            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');

            $table->unsignedTinyInteger('isDeleted')->default(0)->comment('是否删除 0 否 1是');
            $table->collation = 'utf8mb4_general_ci';
            $table->comment   = '活动 - 动作表';
            $table->index(["activityId"], "idx_activityId");
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('activity_action');
    }
}
